package com.tools.cloud.api.model;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
public class CommonResult<T> {
    public static final String success = "success";
    public static final String fault = "fault";

    private String status;

    private T object;

    private List<T> list;

    private String msgInfo;
    private String errInfo;

    public static CommonResult getErrObj(String errInfo) {
        CommonResult result = new CommonResult<>();
        result.setErrInfo(errInfo);
        result.setStatus(fault);
        return result;
    }

    public static CommonResult getSuccessObj(String msgInfo) {
        CommonResult result = new CommonResult<>();
        result.setMsgInfo(msgInfo);
        result.setStatus(success);
        return result;
    }
}
